<!--返回顶部组件-->
<template>
    <div class="backtotop" @click.stop="gototop">
      <i class="iconfont icon-top"></i>
    </div>
</template>
<style>

</style>
<script>
    export default{
        data(){
            return{
                msg:'hello vue'
            }
        },
        components:{

        },
      created:function(){
        $(window).scroll(function () {
          var win_top = $(window).scrollTop()
          var win_height = $(window).innerHeight();
          if (win_top > win_height) {
            $('.backtotop').show();
          }
          if (win_top < win_height) {
            $('.backtotop').hide();
          }
        })
      },
      methods:{
        gototop:function(){
          var win_tops = $(window).scrollTop()
          $('body,html,window').animate({scrollTop: 0}, 500)
        }
      }
    }
</script>
